&lt;!--
@author     Yi Bo &lt;etng2004@gmail.com&gt;
@version    $Id: add.php 39 2007-09-02 12:49:05Z etng2004 $
@copyrithg  2006-2007 ETE.CN
@license    PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
--&gt;
&lt;?php
$this-&gt;declareVars();
echo $this-&gt;render('header.php');
require_once(dirname(__FILE__) . '/_meta_<?php echo $this->controller_name;?>.php');
/*$this-&gt;dump($this-&gt;<?php echo $this->single_object; ?>);*/
$<?php echo $this->single_object; ?> = $this-&gt;<?php echo $this->single_object; ?>;
?&gt;
<form action="&lt;?php echo $this->base_url;?&gt;/add/" method="post" enctype="multipart/form-data" name="frmAdd<?php echo $this->class_object ; ?>" id="frmAdd<?php echo $this->class_object ; ?>">
<table cellpadding="0" cellspacing="0" border="0" class="tblborder">
<tr class="tblhead">
	<td colspan="2">新增</td>
</tr>
<?php
foreach ($this->meta['metadata'] as $column):
if($column['IDENTITY'])
{
	continue;
}else if(substr($column['DATA_TYPE'], 0, strlen('enum')) == 'enum')
{
	/**
	 * 如果为枚举类型，则在语言包中注册翻译，同时设置数组供选择
	 */
	$s = '$enums=array' . substr($column['DATA_TYPE'], strlen('enum')) . ';';
	eval($s);
	$column['enums'] = $enums;
	$lang_variable = "\$LANG['" . strtoupper($column['COLUMN_NAME']) . "']";
	$s = "<?php
	{$lang_variable}= "
	. var_export(array_combine($enums, $enums), true)
	. ";
	\${$column['COLUMN_NAME']}_options = array('"
	. implode('\',\'', $enums)
	. "');
	?>";
	echo $s;
	$column['DATA_TYPE'] = 'enum';
}else if (substr($column['COLUMN_NAME'], -3) == '_id')
{
	$column['DATA_TYPE'] = 'hidden';
?>
<input type="hidden" name="fields[<?php echo $this->single_object; ?>][<?php echo $column['COLUMN_NAME']; ?>]" value="&lt;?php echo $<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>'];?&gt;" id="field_<?php echo $column['COLUMN_NAME']; ?>" />
<?php
	continue;
}
else if (substr($column['COLUMN_NAME'], -3) == '_at')
{
	$column['DATA_TYPE'] = 'datetime';
}
?>
	<tr class="tblbody" >
		<td width="15%">&lt;?php echo $meta['<?php echo $this->single_object; ?>']['fields']['<?php echo $column['COLUMN_NAME']; ?>'];?&gt;</td>
		<td width="85%">
		<?php
		switch ($column['DATA_TYPE'])
		{
			case 'enum':
?>
&lt;?php
      echo $this->formSelect('fields[<?php echo $this->single_object; ?>][<?php echo $column['COLUMN_NAME']; ?>]', @$<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>'], array('id'=>'field_<?php echo $column['COLUMN_NAME']; ?>'), <?php echo $lang_variable; ?>);
      ?&gt;
<?php
				break;
?>
<?php
			case 'datetime':
?>
<input type="text" name="fields[<?php echo $this->single_object; ?>][<?php echo $column['COLUMN_NAME']; ?>]" value="&lt;?php echo $<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>']?date('Y-m-d', $<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>']):'';?&gt;" size="11" id="field_<?php echo $column['COLUMN_NAME']; ?>" />
<script type="text/javascript">
	$(document).ready(function () {
		$('#field_<?php echo $column['COLUMN_NAME']; ?>').calendar();
	});
</script>
<?php
			break;
			case 'text':
?>
&lt;?php
	echo $this->fckeditor('fields[<?php echo $this->single_object; ?>][<?php echo $column['COLUMN_NAME']; ?>]', $<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>'], 'Basic');
	?&gt;
<?php
			break;
			case 'varchar':
			default:
?>
<input type="text" name="fields[<?php echo $this->single_object; ?>][<?php echo $column['COLUMN_NAME']; ?>]" value="&lt;?php echo $<?php echo $this->single_object; ?>['<?php echo $column['COLUMN_NAME']; ?>'];?&gt;" size="11" id="field_<?php echo $column['COLUMN_NAME']; ?>" />
<?php
				break;
		}
?>
		</td>
	</tr>
<?php
endforeach;
?>
<tr class="tblfoot">
	<td colspan="2" align="center"><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
&lt;?php
echo $this-&gt;render('footer.php');
?&gt;